﻿let app=require("express")()
let pdcloud=require("pdcloud")(app)

app.use("/getorderA",async (req,res,next)=>{
    let detail = await pdcloud.getserverdata("product-server", {
        url: "/getdetail",
        req
      })
    if(detail.succeed) {
        detail = JSON.parse(detail.body);
    } else { //获取detail数据失败
        detail = "get detail failed";
    }
    let order={
        detail,
		title: "这是一个没有异常的演示接口",
		price:69.80,
		mainOrderId: "982803586949760080",
		quantity: "1"
    }
    res.json(order)
})
app.use("/getorderB",async (req,res,next)=>{
    let detail = await pdcloud.getserverdata("product-server", {
        url: "/getdetailA",
        req
      })
    if(detail.succeed) {
        detail = JSON.parse(detail.body);
    } else { //获取detail数据失败
        detail = "get detail failed";
    }
    let order={
        detail,
		title: "这是一个调用user-server异常的演示接口",
		price:69.80,
		mainOrderId: "982803586949760080",
		quantity: "1"
    }
    res.json(order)
})
